import { createRouter, createWebHashHistory, RouteRecordRaw } from 'vue-router';
import layout from '../layout/index.vue';

const routes: Array<RouteRecordRaw> = [
  {
    path: '/login',
    name: 'login',
    component: () => import('../views/Login.vue'),
  },
  {
    path: '/',
    name: 'home',
    component: layout,
    redirect: '/home',
    meta: {
      icon: 'el-icon-s-home',
    },
    children: [
      {
        path: 'home',
        name: 'Home',
        component: () => import('../views/home.vue'),
        meta: {
          title: '首页',
        },
      },
    ],
  },
  {
    path: '/list',
    name: 'List',
    component: layout,
    redirect: '/list/list',
    meta: {
      title: '列表页面',
      icon: 'el-icon-s-tools',
    },
    children: [
      {
        path: 'list',
        name: 'List',
        meta: {
          title: '列表1',
        },
        component: () => import('../views/BaseList/list.vue'),
      },
      {
        path: 'list2',
        name: 'List2',
        meta: {
          title: '列表2',
        },
        component: () => import('../views/BaseList/list2.vue'),
      },
    ],
  },
];

const router = createRouter({
  history: createWebHashHistory(),
  routes,
});

export default router;
